package com.r_z.controller;

import com.r_z.service.FinancialRevenueService;
import org.springframework.web.bind.annotation.*;
import com.r_z.entity.FinancialRevenue;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 财务收入
 * @author :yimeng
 * @date :2023/5/30  8:51
 * @description:some description
 */
@RestController
@CrossOrigin
public class FinancialRevenueController {
    @Resource
    FinancialRevenueService financialRevenueService;

    /**
     * 根据主键ID查询
     * @param fRevenueId
     * @return
     */
    @RequestMapping("selectAllFinancialRevenue")
    public List<FinancialRevenue> selectAllFinancialRevenue(String fRevenueId){
        return financialRevenueService.selectAllFinancialRevenue(fRevenueId);
    }

    /**
     * 根据条件查询总行数后进行分页
     * @param page 当前页
     * @param limit 每页显示数
     * @param financialRevenue
     * @return
     */
    @RequestMapping("LimitFinancialRevenue")
    public Map LimitFinancialRevenue(int page,int limit,FinancialRevenue financialRevenue){
        //查询加分页
        List<FinancialRevenue> financialRevenueList = financialRevenueService.LimitFinancialRevenue(page,limit,financialRevenue);
        //查行数
        int count = financialRevenueService.countFinancialRevenue(financialRevenue);
        System.out.println("行数"+count);
        //创建Map对象
        Map map=new HashMap();
        map.put("code",0);
        map.put("msg","");
        map.put("count",count);
        map.put("data",financialRevenueList);
        //返回值
        return map;
    }

    /**
     * 添加财务收入信息
     * @param financialRevenue
     * @return
     */
    @RequestMapping("insertFinancialRevenue")
    public int insertFinancialRevenue(FinancialRevenue financialRevenue){
        return financialRevenueService.insertFinancialRevenue(financialRevenue);
    }

    /**
     * 根据主键ID进行删除财务收入信息
     * @param fRevenueId
     * @return
     */
    @RequestMapping("deleteFinancialRevenue")
    public int deleteFinancialRevenue(String fRevenueId){
        return financialRevenueService.deleteFinancialRevenue(fRevenueId);
    }

    /**
     * 批量删除
     * @param fRevenueId
     * @return
     */
    @RequestMapping("deleteFinancialRevenueById")
    public int deleteFinancialRevenueById(String fRevenueId){
        return financialRevenueService.deleteFinancialRevenueById(fRevenueId);
    }

    /**
     * 根据主键ID修改财务收入信息
     * @param financialRevenue
     * @return
     */
    @RequestMapping("updateFinancialRevenue")
    public int updateFinancialRevenue( FinancialRevenue financialRevenue){
        return financialRevenueService.updateFinancialRevenue(financialRevenue);
    }

}
